package com.oracle.oa.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;









import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.oracle.oa.biz.RoleInfoBiz;
import com.oracle.oa.biz.impl.OperatelogBizImpl;
import com.oracle.oa.entity.Roleinfo;

public class RoleInfoAction extends ActionSupport implements SessionAware {

	public RoleInfoBiz rBiz;
	
//	public int roleinfoid;
	
	public Map<String, Object> session;
	public Roleinfo roleinfo=new Roleinfo();
	public List<Roleinfo> roleinfolist=new ArrayList<Roleinfo>();
	

	public String getAll() {
		roleinfolist=rBiz.getAll(Roleinfo.class);
		session.put("roleinfolist", roleinfolist);
		return SUCCESS;
	}

	public String save() {
		try {
			rBiz.save(roleinfo);
			roleinfo=new Roleinfo();
			OperatelogBizImpl.add("添加", "添加角色");
		} catch (Exception e) {
			roleinfo.setRoleid(0);
		}
		getAll();
		return SUCCESS;
	}
	public String delete(){
		try {
			roleinfo=(Roleinfo) rBiz.getById(Roleinfo.class, roleinfo.getRoleid());
			rBiz.delete(roleinfo);
			OperatelogBizImpl.add("删除", "删除角色");
			roleinfo=new Roleinfo();
		} catch (Exception e) {
			
		}
		getAll();
		return SUCCESS;
	}
	public String one(){
		roleinfo=(Roleinfo) rBiz.getById(Roleinfo.class, roleinfo.getRoleid());
		return SUCCESS;
	}
	public String update(){
		try {
			rBiz.update(roleinfo);
			OperatelogBizImpl.add("修改", "修改角色信息");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		roleinfo=new Roleinfo();
		getAll();
		return SUCCESS;
	}
	public String power(){
		return SUCCESS;
	}

	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

	public Roleinfo getRoleinfo() {
		return roleinfo;
	}

	public void setRoleinfo(Roleinfo roleinfo) {
		this.roleinfo = roleinfo;
	}

	public RoleInfoBiz getrBiz() {
		return rBiz;
	}

	public void setrBiz(RoleInfoBiz rBiz) {
		this.rBiz = rBiz;
	}
	
	
	
	
	

}
